/*
 * @name: 
 * @Author: 卡比
 * @Date: 2021-11-08 17:07:32
 * @LastEditors: 卡比
 * @LastEditTime: 2024-05-10 18:30:31
 */
module.exports = {
	data() {
		return {
			
		}
	},
	onLoad(e) {
		console.log(e);
		if (e.sn) {
			uni.setStorageSync('shareSn', e.sn)
		}
		
		// 设置默认的转发参数
		this.$t.mpShare = {
			// 分享的标题，默认为小程序名称
			title: '',
			// 分享的路径，默认为当前页面
			path: this?.$scope?.route,
			// 分享时显示的图片，默认为当前页面截图
			imageUrl: '',
			// 当前页面是否可以分享
			share: true
		}
		if (!this.$t.mpShare.share) {
			uni.hideShareMenu()
		}
	},
	onShareAppMessage() {

		let obj = {
			...this.$scope.options,
			sn: uni.getStorageSync('userInfo').sn || 0
		}
		let query = Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`)
			.join('&');

		this.$t.mpShare.path += `?${query}`
		console.log(this.$t.mpShare);
		return this.$t.mpShare
	},
	// #ifdef MP-WEIXIN
	onShareTimeline() {
		let obj = {
			...this.$scope.options,
			sn: uni.getStorageSync('userInfo').sn || 0
		}
		let query = Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`)
			.join('&');
		console.log(query);
		return {
			title: this.$t.mpShare.title,
			query,
			// query: this.$t.mpShare.path.substring(this.$t.mpShare.path.indexOf('?') + 1, this.$t.mpShare.path.length),
			imageUrl: this.$t.mpShare.imageUrl
		}
	}
	// #endif
}